package main

import "fmt"

type Swimming interface {
	Swim()
}

type Duck interface {
	// Swimming 这里使用组合方式
	Swimming
}

type Father struct {
	Name string
	Age  int
}

type Son struct {
	Father
}

func (f *Father) getName() string {
	return f.Name
}

func (f *Father) setName(name string) {
	f.Name = name
}

func (f *Father) getAge() int {
	return f.Age
}

func (f *Father) setAge(age int) {
	f.Age = age
}

func (s *Son) getAge() int {
	return s.Age
}

func main() {
	dark := Father{Age: 38, Name: "dark"}
	//开辟了一个新的内存地址，其中的值是父类的值。
	leo := Son{dark}
	fmt.Printf("before change~~ the father is : %v \n", dark)
	fmt.Printf("before change~~ the son  is : %v \n", leo)
	//从这里可以看出,son进行修改后。father结构体并没有被改变.而son中的father结构体是有变化的.
	leo.setAge(5)
	leo.setName("leo")
	fmt.Printf("after change~~ the father is : %v \n", dark)
	fmt.Printf("after change~~ the son's father is : %v \n", leo.Father)
	fmt.Printf("after change~~ the son  is : %v \n", leo)
	fmt.Printf("after change~~ the son  is : %v \n", leo.getName())

}
